In my mind it looks good (although it probably can be done more efficiently?), as it says to first look up all unique names in "foretagsomrade" and create a list. Then for each unique value we select the "annonsor" which has this value in "foretagsomrade"
Hope someone can shed some light on what might be wrong.
I've acturally made a copy of Annonsörer, since I did not know if it would work just by moving. Can this the source of the problem?
Since I've made a copy, I can run the macro from both the old location and the new location - whereas it works in the old location but returns nothing in the new location.
When I do <xsl:copy-of select="$currentPage" /> and compare the result printed on the old and the new location, the only difference is that in the old location I get
So except for the levels being changed, in the old location there is also <umbracoNaviHide />, don't know why this one is not included in the other location - but it feels like the lack of this term should not result in hiding the results, right?
I've tried to print the results from <xsl:key name="omrade" match="*/annonsor" use="foretagsomrade" /> using <xsl:copy-of select="omrade" /> but it returns empty on both pages - so I guess this is not the way to do it.
If I do <xsl:copy-of select="$currentPage/annonsor/foretagsomrade" /> I get the same results on both pages, but then of course I do not get the unique list that I which to have, but one value of foretagsomrade per <annonsor>-node.
Yes - that's the problem - the way grouping works is by (esentially) comparing the current node in the loop with the first node returned from the index created by the "keys stuff" - so in the new location, all the nodes are compared to the nodes from the original location (generate-id() will be unique for two nodes that are otherwise identical - even if they had the same @id).
So yes - that's the problem. If you unpublish the original nodes it should start working...
Is it not possible to get it to work in some other way - would be nice to be able to work with the data in the new location if there is something else needing to be altered before unpublishing the old page?
XSLT grouping stops to work when moved [Umbraco 4.7.0]
Hello!
I'm having some issues when I try to move a document type to a lower level than it is currently in, see figure below:
In the new position, the XSLT-file does not output the same results as for the old position and I can't figure out why. The basic structure is
<annonsarkiv level="3" ...> (child of BTF Magazinet above) <annonsor level="4" ...> (child of Annonsörer above) ... <foretagsomrade>Some text</foretagsomrade> </annonsor> <annonsor level="4" > ... <foretagsomrade>Some other text</foretagsomrade> </annonsor> ...
and the page is suppose to group all "annonsor" by "foretagsomrade" and create something like
Some text
In my mind it looks good (although it probably can be done more efficiently?), as it says to first look up all unique names in "foretagsomrade" and create a list. Then for each unique value we select the "annonsor" which has this value in "foretagsomrade"
Hope someone can shed some light on what might be wrong.
Thanks in advance.
Kind regards
Patrik
Hi Patrik,
You've just moved the Annonsörer node to a new location, right? But are you still executing the macro from the same page as before?
The macro should work if run on the Annonsörer node - because the loops are specifically asking for child nodes of
$currentPage
, named<annonsor>
.Otherwise we'll have to dig deeper... :)
/Chriztian
Hi Chriztian,
I've acturally made a copy of Annonsörer, since I did not know if it would work just by moving. Can this the source of the problem?
Since I've made a copy, I can run the macro from both the old location and the new location - whereas it works in the old location but returns nothing in the new location.
When I do
<xsl:copy-of select="$currentPage" />
and compare the result printed on the old and the new location, the only difference is that in the old location I getwhile in the new location I get
So except for the levels being changed, in the old location there is also
<umbracoNaviHide />
, don't know why this one is not included in the other location - but it feels like the lack of this term should not result in hiding the results, right?I've tried to print the results from
<xsl:key name="omrade" match="*/annonsor" use="foretagsomrade" />
using<xsl:copy-of select="omrade" />
but it returns empty on both pages - so I guess this is not the way to do it.If I do
<xsl:copy-of select="$currentPage/annonsor/foretagsomrade" />
I get the same results on both pages, but then of course I do not get the unique list that I which to have, but one value of foretagsomrade per<annonsor>
-node.Any ideas?
Aha! :)
Yes - that's the problem - the way grouping works is by (esentially) comparing the current node in the loop with the first node returned from the index created by the "keys stuff" - so in the new location, all the nodes are compared to the nodes from the original location (
generate-id()
will be unique for two nodes that are otherwise identical - even if they had the same@id
).So yes - that's the problem. If you unpublish the original nodes it should start working...
/Chriztian
Ah, ok. It worked :)
Is it not possible to get it to work in some other way - would be nice to be able to work with the data in the new location if there is something else needing to be altered before unpublishing the old page?
Great,
Yes, I guess you can scope the
<xsl:key>
to only index the newer nodes, e.g. by using the@level
attribute:Gotta love keys :-)
/Chriztian
Thanks for the help Chriztian!
is working on a reply...